#!/bin/bash

if [[ $# -lt 1 ]]; then
	#statements
	echo 发啥呆呀,输参数呀!!!
	exit;
fi

case $1 in
	"start" )
	echo "又是摸鱼的一天~~"
	echo ===========开启journalnode====================
	ssh hadoop103  hdfs --daemon start journalnode
	ssh hadoop104  hdfs --daemon start journalnode
	ssh hadoop105  hdfs --daemon start journalnode
	echo ===========开启namenode=======================
	ssh hadoop101  hdfs --daemon start namenode
	ssh hadoop102  hdfs --daemon start namenode
	ssh hadoop101  hdfs --daemon start zkfc
        ssh hadoop102  hdfs --daemon start zkfc
	echo ===========开启datanode=======================
	ssh hadoop103  hdfs --daemon start datanode
	ssh hadoop104  hdfs --daemon start datanode
	ssh hadoop105  hdfs --daemon start datanode
	echo ===========开启resourcemanager================
	ssh hadoop101  yarn --daemon start resourcemanager
	ssh hadoop102  yarn --daemon start resourcemanager
	echo ===========开启nodemanager====================
	ssh hadoop103  yarn --daemon start nodemanager
	ssh hadoop104  yarn --daemon start nodemanager
	ssh hadoop105  yarn --daemon start nodemanager
	echo ===========开启历史服务器=====================
	ssh hadoop101 mapred --daemon start historyserver	
	;;
	"stop" )

	echo "下班打游戏去喽!!"
	echo ===========关闭历史服务器=====================
	ssh hadoop101 mapred --daemon stop historyserver
	echo ===========关闭nodemanager====================
	ssh hadoop103  yarn --daemon stop nodemanager
	ssh hadoop104  yarn --daemon stop nodemanager
	ssh hadoop105  yarn --daemon stop nodemanager
	echo ===========关闭resourcemanager================
	ssh hadoop101  yarn --daemon stop resourcemanager
	ssh hadoop102  yarn --daemon stop resourcemanager
	echo ===========关闭datanode=======================
	ssh hadoop103  hdfs --daemon stop datanode
	ssh hadoop104  hdfs --daemon stop datanode
	ssh hadoop105  hdfs --daemon stop datanode
	echo ===========关闭namenode=======================
	ssh hadoop101  hdfs --daemon stop zkfc
        ssh hadoop102  hdfs --daemon stop zkfc

	ssh hadoop101  hdfs --daemon stop namenode
	ssh hadoop102  hdfs --daemon stop namenode
	echo ===========关闭journalnode====================
	ssh hadoop103  hdfs --daemon stop journalnode
	ssh hadoop104  hdfs --daemon stop journalnode
	ssh hadoop105  hdfs --daemon stop journalnode
	
	;;	
	"*" )
	echo 你输入错啦,细心点!!	
	;;
esac
